home *** CD-ROM | disk | FTP | other *** search
/ 1st Multimedia Mac Shareware / Multimedia Shareware CD-ROM - BetaCorp.iso / Hypergames / BrainGames / TicTacToe / stack_-1.xml < prev   
Encoding:
Extensible Markup Language  |  1992-08-11  |  5.4 KB  |  21 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>2</cardCount>
  7.     <cardID>3066</cardID>
  8.     <listID>2143</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>512</width>
  14.         <height>342</height>
  15.     </cardSize>
  16.     <script>on openStack
  17. set userLevel to 5  -- destructive
  18. hide msg
  19. hide menuBar
  20. hide card field 1
  21. hide card field 3
  22. hide card field 4
  23. hide card field 5
  24. hide card field 6
  25. hide card field 7
  26. init
  27. end openStack
  28.  
  29. on macplay
  30. global macpieces,manpieces
  31. set cursor to 4
  32. put "o" into macxo
  33. put "x" into manxo
  34. put empty into macmove
  35. put card field 1 into temphold
  36. -- can mac win?
  37. if macpieces >=2 then
  38. repeat with li = 1 to 9
  39. put char 1 of line li of card field 2 into i
  40. put char 2 of line li of card field 2 into j
  41. if word i of line j of card field array is "e" then
  42. putarray macxo,i,j
  43. if not (winner() is empty) then put i&&j into macmove
  44. put temphold into card field array
  45. if not (macmove is empty) then exit repeat
  46. end if
  47. end repeat
  48. end if
  49. --  can man win on next move?
  50. if manpieces >= 2 then
  51. if macmove is empty then
  52. repeat with li = 1 to 9
  53. put char 1 of line li of card field 2 into i
  54. put char 2 of line li of card field 2 into j
  55. if word i of line j of card field array is "e" then
  56. putarray manxo,i,j
  57. if not (winner() is empty) then put i&&j into macmove
  58. put temphold into card field array
  59. if not (macmove is empty) then exit repeat
  60. end if
  61. end repeat
  62. end if
  63. end if
  64. -- pick randomly
  65. if macmove is empty then
  66. repeat with li = 1 to 9
  67. put char 1 of line li of card field 2 into i
  68. put char 2 of line li of card field 2 into j
  69. if word i of line j of card field array is "e" then
  70. put i&&j into macmove
  71. exit repeat
  72. end if
  73. end repeat
  74. end if
  75. -- restore board
  76. put temphold into card field 1
  77. if not (macmove is empty) then
  78. put word 1 of macmove into boxh
  79. put word 2 of macmove into boxv
  80. putarray macxo, boxh, boxv
  81. add 1 to macpieces
  82. dragit macxo,boxh,boxv
  83. if not (winner() is empty) then play boing "c4 g3 f3 b3 c3"
  84. end if
  85. end macplay
  86.  
  87. -- plays x for man
  88. on manplay boxh,boxv
  89. global manpieces
  90. if not (winner() is empty) then
  91. beep 2
  92. exit manplay
  93. end if
  94. if word boxh of line boxv of card field array is "e" then
  95. put "x" into word boxh of line boxv of card field array
  96. add 1 to manpieces
  97. dragit x,boxh,boxv
  98. if winner() is not empty then
  99. play harpsichord "c d e f g a b c 4"
  100. else macplay
  101. else beep
  102. end manplay
  103.  
  104. on putarray xo,boxh,boxv
  105. put xo into word boxh of line boxv of card field array
  106. end putarray
  107.  
  108. on init
  109. global v0,v1,v2,h0,h1,h2,xloc,oloc,manpieces,macpieces
  110. put "e e e" & return & "e e e" & return & "e e e" into ¬¨
  111. card field array
  112. choose select tool
  113. set cursor to 4
  114. drag from 208,72 to 418,271
  115. doMenu "Trace edges"
  116. doMenu "Clear picture"
  117. choose browse tool
  118. set cursor to 4
  119.  
  120. put 101 into v0
  121. put 171 into v1
  122. put 241 into v2
  123. put 243 into h0
  124. put 314 into h1
  125. put 384 into h2
  126. put "143,289" into xloc
  127. put "67,290" into oloc
  128.  
  129. put 0 into macpieces
  130. put 0 into manpieces
  131.  
  132. end init
  133.  
  134. -- winner returns "(xo) (row/column/diagonal) (1/2/3)"
  135. function winner
  136. put empty into status
  137. repeat with i = 1 to 3
  138. --  check horizontal win
  139. if not (word 1 of line i of card field array is "e") and ¬¨
  140. word 1 of line i of card field array = ¬¨
  141. word 2 of line i of card field array and ¬¨
  142. word 1 of line i of card field array = ¬¨
  143. word 3 of line i of card field array then
  144. put word 1 of line i of card field array && ¬¨
  145. "row" && i into status
  146. end if
  147. --  check vertical win
  148. if not (word i of line 1 of card field array is "e") and ¬¨
  149. word i of line 1 of card field array = ¬¨
  150. word i of line 2 of card field array and ¬¨
  151. word i of line 1 of card field array = ¬¨
  152. word i of line 3 of card field array then
  153. put word i of line 1 of card field array && ¬¨
  154. "column" && i into status
  155. end if
  156. end repeat
  157. --  check diagonal win
  158. if not (word 1 of line 1 of card field array is "e") and ¬¨
  159. word 1 of line 1 of card field array = ¬¨
  160. word 2 of line 2 of card field array and ¬¨
  161. word 1 of line 1 of card field array = ¬¨
  162. word 3 of line 3 of card field array then
  163. put word 1 of line 1 of card field array && ¬¨
  164. "diagonal 1" into status
  165. end if
  166. if not (word 3 of line 1 of card field array is "e") and ¬¨
  167. word 3 of line 1 of card field array = ¬¨
  168. word 2 of line 2 of card field array and ¬¨
  169. word 1 of line 3 of card field array = ¬¨
  170. word 3 of line 1 of card field array then
  171. put word 3 of line 1 of card field array && ¬¨
  172. "diagonal 2" into status
  173. end if
  174. return status
  175. end winner
  176.  
  177. --  dragit (x/o) (123) (123)
  178. on dragit
  179. global v0,v1,v2,h0,h1,h2,xloc,oloc
  180. set cursor to 4
  181. set dragSpeed to 400
  182. if param(1) is "x" then put xloc into thing
  183. else put oloc into thing
  184. if param(2) is 1 then put h0 into desth
  185. if param(2) is 2 then put h1 into desth
  186. if param(2) is 3 then put h2 into desth
  187. if param(3) is 1 then put v0 into destv
  188. if param(3) is 2 then put v1 into destv
  189. if param(3) is 3 then put v2 into destv
  190. set lockScreen to true
  191. push card
  192. go to card "template"
  193. choose lasso tool
  194. click at thing with commandKey
  195. doMenu "Copy picture"
  196. pop card
  197. doMenu "Paste picture"
  198. doMenu "Transparent"
  199. set lockScreen to false
  200. drag from thing to desth,destv
  201.  
  202. choose browse tool
  203. end dragit
  204.  
  205. </script>
  206.     <background id="2594" file="background_2594.xml" name="" />
  207.     <card id="3066" file="card_3066.xml" marked="false" name="playcard" owner="2594" />
  208.     <card id="3187" file="card_3187.xml" marked="false" name="template" owner="2594" />
  209. </stack>
  210.